﻿/**
 * 插入图片插件
 */
(function(E, $){
var Consts = E.consts;

E.plugin("Image", {
	config:{
		width:420,
		position: 'center',
		overlay: true
	},
	init:function(){
		this.cache['html']='<table border="0" width="100%">'
			+'<tr><td width="75">图片地址：</td>'
			+'<td height="25" align="left">'
			+'<input type="text" value="http://" style="width:230px;" name="src" maxlength="250"/>'
			+'</td>'
	
			+'<td align="left"><select title="图片的对齐方式" name="align" style="width:80px;height:21px;">'
			+'<option value="left">左对齐</option>'
			+'<option value="right">右对齐</option></select>'
			+'</td></tr>'

			+'<tr><td>图片连接：</td>'
			+'<td height="25" align="left">'
			+'<input type="text" value="" style="width:230px;" name="url" maxlength="200"/>'
			+'</td>'
			
			+'<td align="left"><select title="打开图片链接的方式" name="target" style="width:80px;height:21px;">'
			+'<option value="_blank" selected>新窗口</option>'
			+'<option value="_self">当前窗口</option></select>'
			+'</td></tr>'
			
			+'</table>';
	},
	
	get: function(panel, self){
		var v = self.getValues( panel ), html='';
		
		if(!/.*?\.(jpg|gif|png)/i.test(v.src)){
			return 1;
		}
		
		html = '<img src="'+v.src+'" align="'+v.align+'" border="0"/>';
		
		if(v.url){
			html = '<a href="'+v.url+'" target="'+v.target+'">'+html+'</a>';
		}
		
		return html+'<br />';
	},
	
	callback: function(){
		var self = this;
	}
});

})(jQEditor, jQuery);